<?php
/**
 * Created by PhpStorm.
 * User: lockie
 * Date: 2019/5/30
 * Time: 14:08
 */

namespace app\index\behavior;
/**
 * Class CORS
 * 允许跨域
 * @author lockie185(lockie185@hotmail.com)
 * @package app\index\behavior
 */
class CORS
{
    public function appInit(&$params)
    {
        header('Access-Control-Allow-Origin:*');
        header("Access-Control-Allow-Headers:token,Origin,X-Requested-With,Content-Type,Accept");
        header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE');
        if (request()->isOptions()) {
            exit();
        }
    }
}